<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@taglib prefix="f" uri="http://www.slim3.org/functions"%>
<%@ page import="jp.co.cos.ittrick.channel.model.ChannelModel" %>
<%@ page import="jp.co.cos.ittrick.channel.model.CategoryModel" %>
<%@ page import="jp.co.cos.ittrick.channel.model.ChapterModel" %>
<%@ page import="jp.co.cos.ittrick.channel.model.PageModel" %>
<%@ page import="java.util.List" %>
<%
	ChannelModel channelModel = (ChannelModel)request.getAttribute("channelModel");
	ChapterModel chapterModel = (ChapterModel)request.getAttribute("chapterModel");
	CategoryModel categoryModel = (CategoryModel)request.getAttribute("categoryModel");
%>
<html lang="ja">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<title>${chapterModel.name }-${channelModel.name }：IT TRICK</title>
	<meta name="description" content="${chapterModel.description }" />
	<meta name="keywords" content="${chapterModel.keyWordListString}" />
	<link rel="icon" type="image/gif" href="/favicon.png" >
	<link rel="alternate" type="application/rss+xml" title="RSS" href="/rss">
	<link href="/css/reset.css" rel="stylesheet" type="text/css" media="screen" />
	<link href="/css/common.css" rel="stylesheet" type="text/css" media="screen" />
	<link href="/css/chapter.css" rel="stylesheet" type="text/css" media="screen" />
	<script src="/js/modernizr-1.1.min.js"></script>
	<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
</head>
<body>
<!--header-->
	<jsp:include page="/common/header.jsp" />
<!--/header-->

<!-- contents -->
	<div id="contents" class="clear">
	<!-- mainContent -->
		<div id="mainContent">
			<article>
				<nav id="pankuzuNav">
					<a href="/">${applicationModel.applicationName }</a>&nbsp;&nbsp;&gt;&nbsp;&nbsp;
					<a href="/${channelModel.keyString}.html">${channelModel.name }</a>&nbsp;&nbsp;&gt;&nbsp;&nbsp;
					${chapterModel.name }
				</nav>

			<!-- mainTopContent -->
				<section id="mainTopContent">
					<header>
						<h1>${chapterModel.name }</h1>
					</header>
					${chapterModel.contentString }
				</section>
			<!-- /mainTopContent -->

			<!-- mainLeftContent -->
				<div id="mainLeftContent">
					<h2>もっと詳しく見てみよう</h2>

					<!-- AdSense -->
					<jsp:include page="/common/adSense/image_468_60.jsp" />
					<!-- /AdSense -->

					<nav class="articleMenu">
						<ul class="chapterlist">
							<%
							List<PageModel> pageList = chapterModel.getPageModelListRef().getModelList();
							for(PageModel pageModel: pageList) {
							%>
							<li class="navi">
								<%if(pageModel.getPublicFlg()) { %>
								<a href="/<%=channelModel.getKeyString() %>/c<%=chapterModel.getKeyString() %>/page<%=pageModel.getKeyString() %>.html"><%=pageModel.getName() %></a>
								<%}else { %>
								<%=pageModel.getName() %>
								<%} %>
							</li>
							<%} %>
						</ul>
					</nav>
				</div>
			<!-- /mainLeftContent -->

			<!-- mainRightContent -->
				<div id="mainRightContent" class="clear">
					<aside>
						<span id="mainRightTitle">${chapterModel.name }に関連のある広告</span>

						<!-- AdSense -->
						<jsp:include page="/common/adSense/text_336_280.jsp" />
						<!-- /AdSense -->
					</aside>
				</div>
			<!-- /mainRightContent -->
			</article>
		</div>
	<!-- /mainContent -->

	<!-- leftContents -->
		<div id="leftContents">

			<!-- AdSense -->
			<jsp:include page="/common/adSense/image_300_250.jsp" />
			<!-- /AdSense -->

			<!-- followMe -->
			<jsp:include page="/common/followMe.jsp" />
			<!-- /followMe -->

			<section>
				<div class="infoBox">
					<header>関連のある記事</header>
					<div class="body">

						<div class="listRelArticle">
							<div class="unitRelArticle">
								<p class="ttlArticle">カテゴリ：<a href="/${channelModel.keyString}.html">${channelModel.name }</a></p>
							</div>

							<%
							List<ChapterModel> chapterList = categoryModel.getChapterModelListRef().getModelList();
							for(ChapterModel chapter: chapterList) {
								String dateTime = new java.text.SimpleDateFormat( "yyyy-MM-dd", java.util.Locale.US).format(chapter.getLastmod());
								String dateValue = new java.text.SimpleDateFormat( "yyyy年MM月dd日", java.util.Locale.US).format(chapter.getLastmod());
							%>
							<div class="unitRelArticle">
								<%if(chapter.getPublicFlg()) { %>
								<p class="ttlArticle">
									<a href="/<%=channelModel.getKeyString() %>/c<%=chapter.getKeyString() %>.html">
										<span class="category">【<%=chapter.getName() %>】</span>
										<%=chapter.getDescription() %>
									</a>
								</p>
								<p class="author">更新日：<time datetime="<%=dateTime%>"><%=dateValue%></time></p>
								<%}else { %>
								<p class="ttlArticle">
									<span class="category">【<%=chapter.getName() %>】</span>
									（未公開）
								</p>
								<%} %>
							</div>
							<%} %>
						</div>
					</div>
				</div>
			</section>

			<!-- socialBtnList -->
				<jsp:include page="/common/socialBtnList.jsp" />
			<!-- /socialBtnList -->

			<!-- profile -->
			<jsp:include page="/common/profile.jsp" />
			<!-- /profile -->

		</div>
	<!-- /leftContents -->
	</div>
<!-- /contents -->

<!--footer-->
	<jsp:include page="/common/footer.jsp" />
<!--/footer-->

<div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) {return;}
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/ja_JP/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
</body>
</html>
